package com.cgbl.service.vm

import android.app.Application
import api.WorkServiceFactory
import com.cgbl.service.assist.DictTypeAssist
import com.robot.base.base.vm.GLBaseViewModel
import com.robot.base.common.api.AbstractViewModelSubscriber
import com.robot.base.model.BaseResponse
import com.robot.base.model.TypeBean
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent

class SetJobViewModel(application: Application) : GLBaseViewModel(application) {

    val list = arrayListOf<String>()

    val uc = UIChangeEvent()

    class UIChangeEvent {
        val showTypeDialog = SingleLiveEvent<Void>()
    }


    val typeCommand = BindingCommand<Any>(BindingAction {
        uc.showTypeDialog.call()
    })

    fun fetchJobList() {
        if (DictTypeAssist.getCareerSource().isEmpty()) {
            DictTypeAssist.refreshCareerDictType {
                initJobLabel(DictTypeAssist.getCareerSource())
            }
            return
        }
        initJobLabel(DictTypeAssist.getCareerSource())
    }

    private fun initJobLabel(careerList: List<TypeBean>) {
        careerList.forEach {
            list.add(it.label ?: "")
        }
    }

}